const Base = require('../base.js');
const tencentcloud = require("tencentcloud-sdk-nodejs")
var config = {
    sdkappid: '1400791281',
    appkey: '0f8609a5aa6560758334d41226fa1288'
}
// 发送短信
module.exports = class extends Base {
    async indexAction() {
        const smsClient = tencentcloud.sms.v20210111.Client
        const client = new smsClient({
            credential: {
                secretId: "AKIDhHk5QcgdQ4nfN5d2GLNG0c3MXUFqKSRI",
                secretKey: "kKlxzzohTDlASZUKzkbbcUO7g7Mfowwp",
            },
            region: "ap-guangzhou",
            profile: {
                signMethod: "HmacSHA256",
                httpProfile: {
                    reqMethod: "POST",
                    reqTimeout: 30,
                    endpoint: "sms.tencentcloudapi.com"
                },
            },
        })
        const params = {
            SmsSdkAppId: config.sdkappid,
            SignName: "乐畅科技", // 签名的名称
            TemplateId: "1671374", // 正文模板id
            TemplateParamSet: [this.get("msg")], // {1}变量的值
            PhoneNumberSet: ["+86" + this.get("phone")],// 接收的手机号码
        }
        client.SendSms(params,  (err, response)=> {
            if (err) {
                console.log(err)
                this.error(err)
                return
            }
            this.success('发送成功')
        })
    }
}




